﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class HomePage_Logon : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (Request.Form["txtName"] != null)
        {
            if (Request.Cookies["CheckCode"] == null)
            {

                Response.Write("<script>alert('您的浏览器设置已被禁用 Cookies，您必须设置浏览器允许使用 Cookies 选项后才能使用本系统！');location.href='../HomePage/Default.aspx';</script>");

            }

            else
            {
                if (String.Compare(Request.Cookies["CheckCode"].Value, SysFun.ToTrim(Request.Form["txtCheckCode"]), true) != 0)
                {

                    Response.Write("<script>alert('验证码错误，请输入正确的验证码。');location.href='../HomePage/Default.aspx';</script>");
                }
                else
                {
                      
                    string strName = Convert.ToString(Request.Form["txtName"]);
                    string strPassword = Convert.ToString(Request.Form["txtPassword"]);
                    string strType = Convert.ToString(Request.Form[2]);
                    //strPassword = SysFun.PasswordEncrypt(strPassword);
                    HZ.MBSM.Model.Account Account = HZ.MBSM.BLL.Login.CheckTradeLogin(strName, strPassword);
                    if (Account == null)
                        Response.Write("<script>alert('用户名或密码不正确，请重新输入。');location.href='../HomePage/Default.aspx';</script>");
                    else
                    {
                        Session["Account"] = Account;
                        //if (strType != Account.Type && strType!="9")
                        //{
                        //    Session["Account"] = null;
                        //    Response.Write("<script>alert('用户类型不正确，请重新选择。');location.href='../HomePage/Default.aspx';</script>");
                        //}
                        //else
                        //{

                        switch (Account.Type)
                        {
                            case "0":
                                Response.Redirect("../Manage/AccountAccredit.aspx");
                                break;
                            case "1":
                                Response.Redirect("../Agency/ProjectList.aspx");
                                break;
                            case "2":
                                
                                    //临时企业登录
                                    Response.Redirect("../Company/ProjectList.aspx");
                               
                                break;
                            case "3":
                                Response.Redirect("../Hospital/HospitalUpdate.aspx");
                                break;
                            case "4": Response.Redirect("../Supervise/PROLIST.aspx");
                                break;

                            case "5":
                               // Response.Redirect("../Manage/GoodsList.aspx");
                                Response.Redirect("../Manage/BefGoodsList.aspx");
                                break;
                            case "6":
                                Response.Redirect("../Manage/CompanyList.aspx");
                                break;
                            case "7":
                                Response.Redirect("../Agency/Check_BidGood_Child.aspx");
                                break;
                            case "8":
                                Response.Redirect("../Agency/bid_project_product_bidTable_listChild.aspx");
                                break;
                            case "9":
                                Response.Redirect("../Expert/ExpertYijia.aspx");
                                break;
                            case "10":
                                Response.Redirect("../Expert/ExpertYijia.aspx");
                                break;
                            case "11":
                                Response.Redirect("../Expert/CompanyYijia.aspx");
                                break;
                            case "12":
                                Response.Redirect("../Expert/CompanyYijia.aspx");
                                break;
                            case "14": //配送审核

                                Response.Redirect("../Agency/Traprojectlist.aspx");
                                break;
                            case "15": //招标各部门
                                Response.Redirect("../Deparment/Deparment_HomePage.aspx");
                                break;
                            case "16"://全能（企业、产品）
                                Response.Redirect("../Manage/CompanyList.aspx");
                                break;
                              
                            case "18": //招标各部门

                                Response.Redirect("../Manage/BoardList.aspx");
                                break;
                            case "41"://监督机构子用户

                                Response.Redirect("../Supervise/TraManage.aspx");
                                break;
                            default:
                                Response.Redirect("../HomePage/Default.aspx");
                                break;
                        }
                        //}
                    }
                }
            }
        }
    }
}
